/**
* 
* ====================================================================
*
* @author apov <apov@ymail.com>
*/ 
#pragma once

#include <BaseDefine.h>
#include <Socket.h>
#include "Network_IOListener.h"

#ifdef WIN32

/**
* @class IOCP_IOListener
*  - 
*/
class NetworkSession;
class IOCP_IOListener : public Network_IOListener{
	enum{
		DEF_SAFE_DELETE_WAIT_TICK=		1000,
	};

public:
	virtual bool initialize( unsigned int event_size, int port, int  back_log );	
	HANDLE getCompletionPort(){ return completionPort_; }	
	virtual bool registerSession( NetworkSession* session );	
	virtual bool unregisterSession( NetworkSession* session );	
	virtual int ioListener_process(){ return 0; }

	static bool availableThisListener();

	IOCP_IOListener();
	virtual ~IOCP_IOListener();

	virtual DEF_THREAD_RETURN run();

protected:
	
private:
	Socket listen_;
	HANDLE completionPort_;
	CThread* worker_;	
};

#endif
